import request from '@/utils/request'

// 查询奖金规则列表
export function listBonusrule(query) {
  return request({
    url: '/rules/bonusrule/list',
    method: 'get',
    params: query
  })
}

// 查询奖金规则详细
export function getBonusrule(ruleId) {
  return request({
    url: '/rules/bonusrule/' + ruleId,
    method: 'get'
  })
}

// 新增奖金规则
export function addBonusrule(data) {
  return request({
    url: '/rules/bonusrule',
    method: 'post',
    data: data
  })
}

// 修改奖金规则
export function updateBonusrule(data) {
  return request({
    url: '/rules/bonusrule',
    method: 'put',
    data: data
  })
}

// 删除奖金规则
export function delBonusrule(ruleId) {
  return request({
    url: '/rules/bonusrule/' + ruleId,
    method: 'delete'
  })
}

// 奖金分配相关接口

// 查询奖金分配列表
export function selectBonusDistributionList(query) {
  return request({
    url: '/rules/bonusrule/distribution/list',
    method: 'get',
    params: query
  })
}

// 匹配奖金规则
export function matchBonusRule(awardId) {
  return request({
    url: '/rules/bonusrule/distribution/match/' + awardId,
    method: 'get'
  })
}

// 执行奖金分配
export function distributeBonus(data) {
  return request({
    url: '/rules/bonusrule/distribution',
    method: 'post',
    data: data
  })
}

// 检查分配权限
export function checkPermission(awardId) {
  return request({
    url: '/rules/bonusrule/distribution/checkPermission/' + awardId,
    method: 'get'
  })
}